package samples
{
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import marcel.core.Plugin;
	import marcel.debug.debug;
	import marcel.display.draw.DrawManager;
	import marcel.display.draw.props.FillProps;
	import marcel.display.screen.MarginProps;
	import marcel.display.screen.ScreenAlignTypes;
	import marcel.display.screen.ScreenItem;
	import marcel.display.screen.ScreenManager;
	import marcel.display.screen.SizeProps;
	import marcel.display.View;
	
	
	public class ScreenManagerSample extends View
	{
		public function ScreenManagerSample() {
			super();
			_initView();
			_innerAndOuter();
		}
		
		
		protected function _innerAndOuter():void {
			debug(ScreenManager.getInnerRec(new Point(100, 50), new Point(200, 200)).toString());
			debug(ScreenManager.getOuterRec(new Point(100, 50), new Point(200, 200)).toString());
		}
		
		protected function _initView():void {
			var _sc:ScreenManager = new ScreenManager(Plugin.plugin.root.stage);
			_sc.addItem(new ScreenItem(addChild(_getSprite()), ScreenAlignTypes.TOP_LEFT, new MarginProps(10, 20, 0, 0)));
			_sc.addItem(new ScreenItem(addChild(_getSprite()), ScreenAlignTypes.BOTTOM_CENTER, new MarginProps(10, 40, 40, 20)));
			_sc.addItem(new ScreenItem(addChild(_getSprite()), ScreenAlignTypes.BOTTOM_CENTER, new MarginProps(10, 40, 40, 20), new SizeProps(1, 20,true, false)));
			var _s:Sprite = _getSprite();
			_s.width = 800;
			_s.height = 600;
			_sc.addItem(new ScreenItem(addChild(_s), ScreenAlignTypes.MIDDLE_CENTER, new MarginProps(0, 0, 0, 0)));
			_sc.addItem(new ScreenItem(addChild(_getSprite()), ScreenAlignTypes.MIDDLE_CENTER, new MarginProps(0, 0, 0, 0), new SizeProps(800, 600,false,false)));
			_sc.addItem(new ScreenItem(addChild(_getSprite()), ScreenAlignTypes.MIDDLE_CENTER, new MarginProps(0, 0, 0, 0)));
			_sc.addItem(new ScreenItem(addChild(_getSprite()), ScreenAlignTypes.BOTTOM_CENTER, new MarginProps(0, 0, 0, 0)));
			
			_sc.enable();
		}
		
		protected function _getSprite():Sprite {
			return DrawManager.drawRect(new Sprite, new Rectangle(0, 0, 100, 100), new FillProps(Math.round(Math.random() * 0xFFFFFF))) as Sprite;
		}
	}
}